package com.liy.cloud.base.service.impl;

import com.liy.cloud.base.dao.BaseOperLineDao;
import com.liy.cloud.base.entity.BaseOperLine;
import com.liy.cloud.base.service.BaseOperLineService;
import com.das.framework.common.dao.IBaseDao;
import com.das.framework.common.service.impl.BaseServiceImpl;
import com.das.framework.common.utils.Tools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * 运营商线路信息表 Service接口服务实现
 * @ClassName: BaseOperLineServiceImpl
 * @Description: 
 * @author zhangw
 * @date: 2019-08-26 22:43:05
 */
@Service
public class BaseOperLineServiceImpl extends BaseServiceImpl<BaseOperLine, String> implements BaseOperLineService{

  @Autowired
  private BaseOperLineDao baseoperlineDao;
  
  @Override
  public IBaseDao<BaseOperLine, String> getDao() {
    return baseoperlineDao;
  }

  @Override
  public void save(ArrayList list, String opId) throws Exception {

    //先删除运营商和线路的关联
    baseoperlineDao.deleteByPrimaryKey(opId);
    for(int i=0;i<list.size();i++){
      //再插入关联
      BaseOperLine baseOperLine = new BaseOperLine();
      baseOperLine.setId(Tools.getNewUUID());
      baseOperLine.setOpId(opId);
      baseOperLine.setLineId(list.get(i).toString());
      baseoperlineDao.insertSelective(baseOperLine);
    }
  }
}